﻿using System;
using DBAccessLibrary.Common;

namespace DBAccessLibrary.Model
{
    [Serializable]
    public class BaseConnection : BasePropertyChange
    {
        private string _connectionStr;
        public string ConnectionStr
        {
            get { return _connectionStr; }
            set
            {
                _connectionStr = value;
                this.NotifyPropertyChanged(o => o.ConnectionStr);
            }
        }
    }

    [Serializable]
    public class ConnectionModel : BaseConnection
    {
        private string _server;
        private string _database;
        private string _userid;
        private string _password;
        private DBType _type;

        public string Server
        {
            get { return _server; }
            set
            {
                _server = value;
                this.NotifyPropertyChanged(o => o.Server);
            }
        }

        public string DataBase
        {
            get { return _database; }
            set
            {
                _database = value;
                this.NotifyPropertyChanged(o => o.DataBase);
            }
        }

        public string UserID
        {
            get { return _userid; }
            set 
            {
                _userid = value;
                this.NotifyPropertyChanged(o => o.UserID);
            }
        }

        public string PassWord
        {
            get { return _password; }
            set
            {
                _password = value;
                this.NotifyPropertyChanged(o => o.PassWord);
            }
        }


        public DBType ConnectType
        {
            get { return _type; }
            set
            {
                _type = value;
                this.NotifyPropertyChanged(o => o.ConnectType);
            }
        }

        public bool Compare(ConnectionModel model)
        {
            if (this._database == model.DataBase &&
                this._password == model.PassWord &&
                this._server == model.Server &&
                this._type == model.ConnectType &&
                this._userid == model.UserID)
                return true;
            return false;
        }
    }
}
